package zhouzhouyongche.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table(name = "t_order")
@DynamicInsert(true)
@DynamicUpdate(true)
//订单表，包含已付款和未付款的订单，还可以包含下订单的日期
public class Order implements Serializable{
	private static final long serialVersionUID = 1L;

	//主键
	private String orderCode;
	
	private City startCity;
	private PassengerStation startPassengerStation;
	private City endCity;
	private Site endSite;
	private Year year;
	private Month month;
	private Day day;
	private Hour hour;
	private Minute minute;
	private Passenger passenger;
	private Passenger ticketPicker;
	private String phoneNumberOfTicketPicker;
	private String busType;
	private float price;
	private int seatNumber;
	
	// 0 表示“支付成功”， 1 表示“支付失败”， 2 表示“未支付”，3表示“取消订单”，4表示“等待付款” 5表示“交易关闭”
	private int status;

	@Id
	public String getOrderCode() {
		return orderCode;
	}

	public void setOrderCode(String orderCode) {
		this.orderCode = orderCode;
	}

	//Order与City为单向关系(One To One)，即 Order -> City
	@OneToOne
	@JoinColumn(name = "city_id",nullable = false)
	public City getStartCity() {
		return startCity;
	}

	public void setStartCity(City startCity) {
		this.startCity = startCity;
	}

	//Order与PassengerStation为单向关系(One To One)，Order -> PassengerStation
	@OneToOne
	@JoinColumn(name = "startPassengerStation_id", nullable = false)
	public PassengerStation getStartPassengerStation() {
		return startPassengerStation;
	}

	public void setStartPassengerStation(PassengerStation startPassengerStation) {
		this.startPassengerStation = startPassengerStation;
	}

	//Order与City为单向关系(One To One)，即 Order -> City
	@OneToOne
	@JoinColumn(name = "endCity_id", nullable = false)
	public City getEndCity() {
		return endCity;
	}

	public void setEndCity(City endCity) {
		this.endCity = endCity;
	}

	@Column(nullable = false)
	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	// 0 表示支付成功， 1 表示支付失败， 2 表示未支付
	@Column(columnDefinition = "int default 0")
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	@OneToOne
	@JoinColumn(name = "passenger_id", nullable = false)
	public Passenger getPassenger() {
		return passenger;
	}

	public void setPassenger(Passenger passenger) {
		this.passenger = passenger;
	}

	@OneToOne
	@JoinColumn(name = "year_id", nullable = false)
	public Year getYear() {
		return year;
	}

	public void setYear(Year year) {
		this.year = year;
	}
	
	@OneToOne
	@JoinColumn(name = "month_id", nullable = false)
	public Month getMonth() {
		return month;
	}

	public void setMonth(Month month) {
		this.month = month;
	}

	@OneToOne
	@JoinColumn(name = "day_id", nullable = false)
	public Day getDay() {
		return day;
	}

	public void setDay(Day day) {
		this.day = day;
	}

	@OneToOne
	@JoinColumn(name = "passenger_ticketPicker_id", nullable = false)
	public Passenger getTicketPicker() {
		return ticketPicker;
	}

	public void setTicketPicker(Passenger ticketPicker) {
		this.ticketPicker = ticketPicker;
	}

	@Column(name = "phoneNumberOfTicketPicker", nullable = false)
	public String getPhoneNumberOfTicketPicker() {
		return phoneNumberOfTicketPicker;
	}

	public void setPhoneNumberOfTicketPicker(String phoneNumberOfTicketPicker) {
		this.phoneNumberOfTicketPicker = phoneNumberOfTicketPicker;
	}

	@Column(nullable = false)
	public String getBusType() {
		return busType;
	}

	public void setBusType(String busType) {
		this.busType = busType;
	}

	@OneToOne
	@JoinColumn(name = "hour_id", nullable = false)
	public Hour getHour() {
		return hour;
	}

	public void setHour(Hour hour) {
		this.hour = hour;
	}

	@OneToOne
	@JoinColumn(name = "minute_id", nullable = false)
	public Minute getMinute() {
		return minute;
	}

	public void setMinute(Minute minute) {
		this.minute = minute;
	}

	@OneToOne
	@JoinColumn(name = "endSite_id", nullable = false)
	public Site getEndSite() {
		return endSite;
	}

	public void setEndSite(Site endSite) {
		this.endSite = endSite;
	}

	@Column
	public int getSeatNumber() {
		return seatNumber;
	}

	public void setSeatNumber(int seatNumber) {
		this.seatNumber = seatNumber;
	}
	
}
